<template>
    <a-spin :spinning="confirmLoading" style="background: #fff">
      <j-form-container :disabled="false">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row :gutter="48">
            <a-col :span="8" :hidden="true">
              <a-form-model-item label="流程名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle" >
                <a-input :max-length="255" :disabled="checkDisabled('')" v-model="model.bpmBizTitle" placeholder="请输入流程名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="档案编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="finalNo">
                <a-input :disabled="true" v-model="model.finalNo" placeholder="请输入档案编号"></a-input>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8">
              <a-form-model-item label="申请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
                <j-date :disabled="true" placeholder="请选择申请时间" v-model="model.createTime" style="width: 100%"/>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8">
              <a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handlerId">
                <select-user-by-dep disabled :multi="false" v-model="model.handlerId"/>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8">
              <a-form-model-item label="申请部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handlerDeptId">
                <j-select-depart :disabled="true" v-model="model.handlerDeptId"/>
              </a-form-model-item>
            </a-col>
  
            <a-divider>基本信息</a-divider>
            <a-col :span="8">
              <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmmc">
                <a-input
                  readOnly
                  @click.prevent="onDetail(model.id, 'project')"
                  v-model="model.projectName"
                  style="color: #1890FF; cursor: pointer;"
                  placeholder="请选择项目"></a-input>
              </a-form-model-item>
            </a-col>

            <a-col :span="8">
              <a-form-model-item label="研发归属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year">
                <!-- <j-dict-select-tag disabled placeholder="请选择研发归属年度" v-model="model.auditStatus" dictCode="audit_status"/> -->
                <j-dict-select-tag disabled placeholder="请选择研发归属年度" v-model="model.year" dictCode="yjgsnd"/>
              </a-form-model-item>
            </a-col>

            <a-col :span="8">
              <a-form-model-item label="研发类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htmc">
                <j-dict-select-tag disabled placeholder="请选择研发类型" v-model="model.developmentType" dictCode="development_type"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目负责人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectLeading">
                <select-user-by-dep
                disabled
                v-model="model.undertaker"
              />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="费用所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamName">
                <select-team-input
                disabled
                v-model="model.teamName"
                :tdlx="3"
                placeholder="请输入费用所属团队"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="甲方单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signUnit">
                <select-Company-input disabled placeholder="请选择甲方单位" v-model="model.signUnit" />
                <!-- <j-dict-select-tag disabled placeholder="请选择甲方单位" v-model="model.auditStatus" dictCode="audit_status"/> -->
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="乙方单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplierId">
                <!-- <j-dict-select-tag disabled placeholder="请选择乙方单位" v-model="model.auditStatus" dictCode="audit_status"/> -->
                <!-- <select-Company-input disabled placeholder="请选择乙方单位" v-model="model.supplierId" /> -->
                <select-customer-input disabled commercialType="2" v-model="model.supplierId" />

              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htmc">
                <j-dict-select-tag
                  disabled
                  type="list"
                  v-model="model.contacts"
                  :dictCode="cust_lxr"
                  placeholder="请选择联系人"
                  @change="lxrChange"
                  :triggerChange="true"/>
              </a-form-model-item>
            </a-col>

            <a-col :span="8">
              <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactTel">
                <a-input :disabled="formDisabled" v-model="model.contactTel" placeholder="请输入联系电话" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="立项日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jytd">
                <j-date
                disabled
                placeholder="请选择立项日期"
                v-model="model.projectEstablishDate"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm"
                style="width: 100%" />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row :gutter="48">

            <a-divider style="top:20px;">预计研发费用</a-divider>
            <a-col :span="8">
              <a-form-model-item label="预计研发费合计(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedContractAmount">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedContractAmount"
                  placeholder="请输入预计研发费"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>

            <a-col :span="8">
              <a-form-model-item label="预计研发费用合计大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedContractcapitalChineseAmount">
                <a-input :disabled="true" v-model="model.estimatedContractcapitalChineseAmount" placeholder="请输入"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计人员人工费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedPersonalFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedPersonalFee"
                  placeholder="请输入预计人员人工费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计直接投入费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedDirectPutFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedDirectPutFee"
                  placeholder="请输入预计直接投入费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计折旧与摊销费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedDepreciationAmortizeFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedDepreciationAmortizeFee"
                  placeholder="请输入预计折旧与摊销费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计调试与试验费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedExperimentFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedExperimentFee"
                  placeholder="请输入预计调试与试验费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计委外开发费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedOutsourceDevelopmentFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedOutsourceDevelopmentFee"
                  placeholder="请输入预计委外开发费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="预计其它费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedOtherFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.estimatedOtherFee"
                  placeholder="请输入预计其它费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row :gutter="48">

            <a-divider style="top:20px;">实际研发费用</a-divider>
            <a-col :span="8">
              <a-form-model-item label="实际研发费合计(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualDevelopmentFeeAmount">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualDevelopmentFeeAmount"
                  placeholder="请输入实际研发费"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>

            <a-col :span="8">
              <a-form-model-item label="实际研发费用合计大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualDevelopmentFeeChineseAmount">
                <a-input :disabled="true" v-model="model.actualDevelopmentFeeChineseAmount" placeholder="请输入"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际人员人工费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualPersonalFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualPersonalFee"
                  placeholder="请输入实际人员人工费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际直接投入费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualDirectPutFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualDirectPutFee"
                  placeholder="请输入实际直接投入费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际折旧与摊销费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualDepreciationAmortizeFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualDepreciationAmortizeFee"
                  placeholder="请输入实际折旧与摊销费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际调试与试验费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualExperimentFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualExperimentFee"
                  placeholder="请输入实际调试与试验费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际委外开发费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualOutsourceDevelopmentFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualOutsourceDevelopmentFee"
                  placeholder="请输入实际委外开发费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="实际其它费用(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualOtherFee">
                <a-input-number
                  :precision="2"
                  disabled
                  :max="99999999"
                  :min="0"
                  v-model="model.actualOtherFee"
                  placeholder="请输入实际其它费用"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
                <a-row :gutter="48">
            <a-divider style="top:20px;">项目状态</a-divider>
            <a-col :span="8">
              <a-form-model-item label="项目档案状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPerformance">
                
                <j-dict-select-tag placeholder="请选择项目档案状态" disabled v-model="model.currentProjectStatus" dictCode="current_project_status"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="变更状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPerformance">
                <j-dict-select-tag placeholder="请选择变更状态" disabled v-model="model.changeStatus" dictCode="change_status"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="结项状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPerformance">
                <j-dict-select-tag placeholder="请选择结项状态" disabled v-model="model.conclusionStatus" dictCode="conclusion_status"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="结项时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="conclusionDate">
                <j-date
                disabled
                placeholder="请选择结项时间"
                v-model="model.conclusionDate"
                :show-time="true"
                date-format="YYYY-MM-DD"
                style="width: 100%" />
              </a-form-model-item>
            </a-col>

            <a-col :span="24">
              <a-form-model-item label="立项事由及说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="establishReason">
                <a-textarea :maxLength="500" disabled  v-model="model.establishReason" rows="4" placeholder="请输入"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="相关附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment">
                <div style="display: flex;">
                  <j-upload   v-model="model.attachment"></j-upload>
                  <a-button  type="primary" @click="sumbitFile">提 交</a-button>
                </div>
               
                <!-- <a-button  icon="download" @click="viewFile(model.attachment)">文件列表</a-button> -->
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
        <common-flow-list v-if="formBpm && model.bpmStatus !== '1'" :formData="formData" style="margin-top: 10px"></common-flow-list>
        <view-file-modal ref="viewFileModal"></view-file-modal>
  
        <!-- 项目详情开始 -->
        <erp-project-report-modal ref="projectModalForm"></erp-project-report-modal>
        <!-- 项目详情结束 -->
        <!--收付款计划-->
        <!-- <erp-omc-contract-manager-plan-modal
          :htlx="model.htlx"
          :projectId="model.xmmc"
          :bchte="remainBchte"
          :lx="model.lx"
          :dataSource="dataSource"
          ref="itemList"
          @ok="modalFormOk"></erp-omc-contract-manager-plan-modal> -->
        <!-- <erp-omc-contract-manager-class-modal ref="itemList2" @ok="modalFormOk2"></erp-omc-contract-manager-class-modal>
        <erp-omc-contract-manager-trustee-modal
          :htlx="model.htlx"
          :signSealWay="model.signSealWay"
          ref="itemList3"
          @ok="modalFormOk3"></erp-omc-contract-manager-trustee-modal>
        <erp-omc-contract-manager-entrust-modal
          :htlx="model.htlx"
          :signSealWay="model.signSealWay"
          ref="itemList4"
          @ok="modalFormOk4"></erp-omc-contract-manager-entrust-modal> -->
      </j-form-container>
      <!-- <a-col :span="24">
            <a-table
              ref="table"
              size="middle"
              rowKey="id"
              bordered
              :scroll="{x:scrollX}"
              :components="draggableComponent"
              :loading="loading"
              :columns="columns"
              :pagination="false"
              :data-source="dataSource">
              <span slot="action" slot-scope="text, record">
                <template v-if="!formDisabled">
                  <a-button class="ruleButton" :ghost="true" type="primary" icon="edit" @click="handleEdit(record)" />
                  <a-divider type="vertical" />
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a-button class="ruleButton" :ghost="true" type="primary" icon="delete" />
                  </a-popconfirm>
                </template>
                <template v-if="record.billNo">
                  <a @click="handleDetail(record)">详情</a>
                </template>
              </span>
            </a-table>
          </a-col> -->
          <a-row>
                <a-col :span="24">
                <a-tabs @change="changeProjectTab">
                  <a-tab-pane tab="研发任务" :forceRender="true" key="1">
                    <a-row :gutter="24">
                      <a-col :span="24">
                        <a-table
                          ref="table"
                          size="middle"
                          bordered
                          :scroll="{ x: scrollXOther }"
                          :components="draggableComponentOther"
                          :pagination="false"
                          :columns="columns"
                          :dataSource="devDataSource"
                          :loading="loading">
                          <template slot="status" slot-scope="status">
                            <a-badge :status="status | statusTypeFilter" :text="status | statusFilter" />
                          </template>
                          <template slot="htmlSlot" slot-scope="text">
                            <div v-html="text"></div>
                          </template>
                          <template slot="imgSlot" slot-scope="text">
                            <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                            <img
                              v-else
                              :src="getImgView(text)"
                              height="25px"
                              alt=""
                              style="max-width:80px;font-size: 12px;font-style: italic;" />
                          </template>
                          <template slot="fileSlot" slot-scope="text">
                            <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                            <a-button
                              v-else
                              :ghost="true"
                              type="primary"
                              icon="download"
                              size="small"
                              @click="downloadFile(text)">
                              下载
                            </a-button>
                          </template>
                          <a slot="projectNo" slot-scope="text, record" @click="handleViews(record.projectId)">{{ text
                          }}</a>
                        </a-table>
                      </a-col>
                    </a-row>
                  </a-tab-pane>
                </a-tabs>
              </a-col>
          </a-row>

          <a-row>
            <a-col :span="24">
              <a-tabs @change="handleChangeTab">
                <a-tab-pane tab="任务进度" :forceRender="true" key="1">
                  <a-row :gutter="24">
                    <a-col :span="24">
                      <a-table
                        ref="table"
                        rowKey="id"
                        size="middle"
                        bordered
                        :scroll="{ x: scrollXOther }"
                        :components="draggableComponentOther"
                        :pagination="false"
                        :columns="taskProgressColumns"
                        :dataSource="progressListDataSource"
                        :loading="loading">
                        <template slot="status" slot-scope="status">
                          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter" />
                        </template>
                        <template slot="htmlSlot" slot-scope="text">
                          <div v-html="text"></div>
                        </template>
                        <template slot="imgSlot" slot-scope="text">
                          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                          <img
                            v-else
                            :src="getImgView(text)"
                            height="25px"
                            alt=""
                            style="max-width:80px;font-size: 12px;font-style: italic;" />
                        </template>
                        <template slot="fileSlot" slot-scope="text">
                          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                          <a-button
                            v-else
                            :ghost="true"
                            type="primary"
                            icon="download"
                            size="small"
                            @click="downloadFile(text)">
                            下载
                          </a-button>
                        </template>
                        <a slot="projectNo" slot-scope="text, record" @click="handleViews(record.projectId)">{{ text
                        }}</a>
                      </a-table>
                    </a-col>
                  </a-row>
                </a-tab-pane>
              </a-tabs>
          </a-col>
          </a-row>

      <a-row :gutter="48">
        <a-col :span="24" style="text-align: center;margin-top: 15px">
          <a-button type="primary" v-if="formBpm" :style="{ marginRight: showFlowSubmitButton?'10px':'0px' }" @click="onPrint">打印</a-button>
          <!-- <a-button  type="primary" @click="sumbitFile">提 交</a-button> -->
        </a-col>
      </a-row>
  
      <ErpOmcContractManagerFormPrint v-if="formBpm && isSubmit" class="print_style" id="contractmanageContent" :formData="model1" :formDataHistory="formData"></ErpOmcContractManagerFormPrint>
  
      <ErpPurchaseCalibrationBillPenetrate ref="purchaseCalibrationBillPenetrate" ></ErpPurchaseCalibrationBillPenetrate>
  
      <ErpPurchaseApplyFormPenetrate ref="purchaseApplyFormPenetrate" ></ErpPurchaseApplyFormPenetrate>
      <ErpPurchaseApplyInvitationPenetrate ref="purchaseInvitationFormPenetrate" ></ErpPurchaseApplyInvitationPenetrate>
  
      <a-modal
        :maskClosable="false"
        title="框架合同档案详情"
        :width="1350"
        :bodyStyle="{
          padding: '0 24px'
        }"
        :visible="contractVisible"
        @cancel="handleCancel"
        cancelText="关闭">
        <a-card
          :bordered="false"
          :bodyStyle="{
            padding: '10px 24px'
          }">
          <ErpOmcContractManagerDetailForm ref="contractManageForm" :disabled="true" files normal></ErpOmcContractManagerDetailForm> <!-- 收款合同 -->
        </a-card>
        <template slot="footer">
          <a-button @click.stop="()=>{contractVisible=false}">关闭</a-button>
        </template>
      </a-modal>
    </a-spin>
  </template>
  
  <script>
  import { getAction, httpAction } from '@/api/manage'
  import { viewFile } from '@/utils/util'
  import SelectProjectInput from '@/views/scy/components/SelectProjectInput'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import SelectContractInput from '@/views/scy/components/SelectContractInput'
  import { convertCurrency } from '@/utils/MoneyConvert'
  import ViewFileModal from '@/views/scy/components/ViewFileModal'
//   import ErpOmcContractManagerPlanModal from '../modules/ErpOmcContractManagerPlanModal'
//   import ErpOmcContractManagerClassModal from '../modules/ErpOmcContractManagerClassModal'
//   import ErpOmcContractManagerTrusteeModal from '../modules/ErpOmcContractManagerTrusteeModal'
//   import ErpOmcContractManagerEntrustModal from '../modules/ErpOmcContractManagerEntrustModal'
//   import ErpOmcContractTaxRateInfoList from './modules/ErpOmcContractTaxRateInfoList' // 税率列表
  import { filterMultiDictText, initDictOptions, filterDictTextByCache } from '@/components/dict/JDictSelectUtil'
  import SelectContractManagerInput from '@/views/scy/components/SelectContractManagerInput'
  import SelectContractNumberInput from '@/views/scy/components/SelectContractNumberInput'
  import moment from 'moment';
  import { mapGetters } from 'vuex';
  import { message } from 'ant-design-vue'
  import { JVXETypes } from '@/components/jeecg/JVxeTable'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectPurchaseCalibrationInput from '@/views/scy/components/SelectPurchaseCalibrationInput'
  import CommonFlowList from '@/views/components/CommonFlowList.vue';
  import ErpProjectReportModal from '@/views/erp/report/project/modules/ErpProjectReportModal'
  import SelectPurchaseApplyFormContractInput from '@/views/scy/components/SelectPurchaseApplyFormContractInput'
  import Print from '@/utils/print/printarea.js';
//   import ErpOmcContractManagerFormPrint from './ErpOmcContractManagerFormPrint' // 打印
  import SelectPurchasingRequisitionInput from '@/views/scy/components/SelectPurchasingRequisitionInput'
  import ErpPurchaseCalibrationBillPenetrate from '@/views/scy/penetrate/ErpPurchaseCalibrationBillPenetrate'
  import ErpPurchaseApplyFormPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyFormPenetrate'
  import ErpPurchaseApplyInvitationPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyInvitationPenetrate'
  import ErpOmcContractManagerDetailForm from '@/views/erp/omc/contractmanager/modules/ErpOmcContractManagerDetailForm' // 框架合同档案表单
  import { DragResizable } from '@/mixins/DragResizable'
  import Decimal from 'decimal.js'
  export default {
    name: 'ErpFileManagementFormDetail',
    mixins: [viewFile, DragResizable],
    components: { // select-customer-input
      SelectPurchaseApplyFormContractInput,
      SelectPurchaseCalibrationInput,
      SelectProjectInput,
      SelectTeamInput,
      SelectUserByDep,
      SelectCustomerInput,
      SelectContractInput,
      ViewFileModal,
    //   ErpOmcContractManagerPlanModal,
    //   ErpOmcContractManagerClassModal,
    //   ErpOmcContractManagerTrusteeModal,
    //   ErpOmcContractManagerEntrustModal,
      SelectContractManagerInput,
      SelectContractNumberInput,
      SelectCompanyInput,
      CommonFlowList,
      ErpProjectReportModal,
    //   ErpOmcContractManagerFormPrint,
      SelectPurchasingRequisitionInput,
      ErpPurchaseCalibrationBillPenetrate,
      ErpPurchaseApplyFormPenetrate,
      ErpPurchaseApplyInvitationPenetrate,
    //   ErpOmcContractTaxRateInfoList, // 税率列表
      ErpOmcContractManagerDetailForm
    },
    props: {
      // 流程表单data
      formData: {
        type: Object,
        default: () => {
        },
        required: false
      },
      // 表单模式：true流程表单 false普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data() {
      return {
        isSubmit: true, // 打印控制按钮
        modelDefault: {},
        model: {
          // 迭代11 1.是否用章改为是否用印，变更为必选项，不给默认值
          // sfyz: 0,
          glskht: 0,
          sfbgkxxx: 0,
          jf: undefined,
          yf: undefined,
          involveMultiple: 0
        },
        // 打印
        model1: {
          // 迭代11 1.是否用章改为是否用印，变更为必选项，不给默认值
          // sfyz: 0,
          glskht: 0,
          sfbgkxxx: 0,
          jf: undefined,
          yf: undefined,
          involveMultiple: 0
        },
        createTime: [],
        progressListDataSource:[],
        devDataSource:[],
        labelCol: {},
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 }
        },
        confirmLoading: false,
        contractVisible: false, // 弹窗显隐
        validatorRules: {
          bchte: [
            { required: true, message: '请输入本次合同额!' }
          ],
          businessPerformance: [
            { required: true, message: '请输入经营绩效!' }
          ],
          fwqx: [
            { required: true, message: '请选择服务期限!' }
          ],
          htlx: [
            { required: true, message: '请输入合同类型!' }
          ],
          htmc: [
            { required: true, message: '请输入合同名称!' }
          ],
          // xmmc: [
          //   { required: true, message: '请选择项目名称!' }
          // ],
          jytd: [
            { required: true, message: '请选择经营团队!' }
          ],
          yjgsnd: [
            { required: true, message: '请选择业绩归属年度!' }
          ],
          qddw: [
            { required: true, message: '请选择签订单位!' }
          ],
          isFrameContract: [
            { required: true, message: '请选择框架下合同!' }
          ],
          frameContractId: [
            { required: true, message: '请选择关联框架合同!' }
          ],
          ownerRole: [
            { required: true, message: '请选择业主角色!' }
          ],
          xmcjr: [
            { required: true, message: '请选择项目承接人!' }
          ],
          yzdw: [
            { required: true, message: '请选择业主单位!' }
          ],
          // qdrq: [
          //   { required: true, message: '请输入签订日期!' }
          // ],
          yzlx: [
            { required: true, message: '请选择印章类型!' }
          ],
          noFormalContract: [
            { required: true, message: '请选择无正式合同!' }
          ],
          signSealWay: [
            { required: true, message: '请选择用印类型!' }
          ],
          distributionMethod: [
            { required: true, message: '请选择分配方式!' }
          ],
          yyfs: [
            { required: true, message: '请填写用印份数!', trigger: 'blur' },
            { pattern: /^[0-9]*[1-9][0-9]*$/, message: '请输入正整数!' }
          ],
          lxfs: [
            { required: false },
            { pattern: /(^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$)|(^\/$)/, message: '请输入正确的联系方式!' }
          ],
          masterCopy: [
            { required: true, message: '请上传合同原件!' }
          ],
          sfyz: [
            { required: true, message: '请选择是否用印!' }
          ],
          signFile: [
            { required: true, message: '请上传用印文件!' }
          ],
          feeType: [
            { required: true, message: '请选择费用类型!' }
          ],
          contractChangeReason: [
            { required: true, message: '请输入变更说明!' }
          ],
          // sfcd: [
          //   { required: true, message: '请选择是否存档!' }
          // ],
          // cdfs: [
          //   { required: true, message: '请输入存档份数!' }
          // ]
        },
        url: {
          ProgressTaskList: '/api/erp/progress/development/erpProgressTask/progressList',
          add: '/api/erp/omc/contractmanager/erpOmcContractManager/add',
          edit: '/api/erp/omc/contractmanager/erpOmcContractManager/edit',
          queryById: '/api/erp/omc/contractmanager/erpOmcContractManager/queryById',
          queryPlanList: '/api/erp/omc/contractmanager/erpOmcContractManagerPlan/listAll',
          queryClassList: '/api/erp/omc/contractmanager/erpOmcContractManagerClass/listAll',
          queryClassList2: '/api/erp/omc/project/erpOmcProjectTask/list',
          queryEntrustList: '/api/erp/omc/contractmanager/erpOmcContractManagerEntrust/listAll',
          queryTrusteeList: '/api/erp/omc/contractmanager/erpOmcContractManagerTrustee/listAll',
          queryProjectDeposit: '/api/erp/finance/deposit/erpFinanceProjectDepositBill/queryByEntity',
          generatedFormNumber: '/api/erp/base/generatedFormNumber',
          queryProjectById: '/api/erp/project/report/erpProjectReport/queryById',
          // 获取定标结果确认单信息
          queryCalibrationById: '/api/erp/purchase/procurement/erpPurchaseCalibration/queryById',
          // 获取采购申请单信息
          queryPurchaseApplyById: '/api/erp/purchase/procurement/erpPurchaseApplyForm/queryById',
          // 获取招标采购单信息
          queryInvitationById: '/api/erp/purchase/procurement/erpPurchaseApplyInvitation/queryById',
          queryProject: '/api/erp/omc/project/erpOmcProject/queryById'
        },
        loading: false,
         taskProgressColumns: [
        {
          title: '序号',
          align: 'center',
          dataIndex: '',
          key: 'rowIndex',
          // fixed: 'left',
          width: 60,
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
          // fixed: 'left',
          ellipsis: true,
          width: 170
        },

        {
          title: '任务档案编号',
          align: 'center',
          dataIndex: 'taskBillNo',
          // fixed: 'left',
          ellipsis: true,
          width: 170,
        },
        {
          title: '业务分类',
          align: 'center',
          dataIndex: 'categoryName',
          ellipsis: true,
          width: 170
        },
        {
          title: '研发团队',
          align: 'center',
          dataIndex: 'productTeam_dictText',
          ellipsis: true,
          width: 170
        },
        {
          title: '研发负责人',
          align: 'center',
          dataIndex: 'projLeadName',
          ellipsis: true,
          width: 105
        },
        {
          title: '任务进度',
          align: 'center',
          dataIndex: 'taskProgress',
          ellipsis: true,
          width: 90,
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },

        {
          title: '进度百分比(%)',
          align: 'center',
          dataIndex: 'contractRate',
          ellipsis: true,
          width: 115
        },
        {
          title: '是否变更中',
          align: 'center',
          dataIndex: 'changeStatus_dictText',
          ellipsis: true,
          width: 115
        },
        {
          title: '任务状态',
          align: 'center',
          dataIndex: 'distributionType_dictText',
          ellipsis: true,
          width: 170
        },
        {
          title: '完成时间',
          align: 'center',
          dataIndex: 'completeTime',
          ellipsis: true,
          width: 170
        },

        ],
        columns: [
        {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '任务档案编号',
            align: 'center',
            dataIndex: 'billNo',
            width: 151,
            ellipsis: true
          },
          {
            title: '业务分类编码',
            align: 'center',
            dataIndex: 'categoryCode',
            width: 106,
            ellipsis: true
          },

          {
            title: '业务分类名称',
            align: 'center',
            dataIndex: 'categoryName',
            width: 104,
            ellipsis: true
          },
          {
            title: '研发团队',
            align: 'center',
            dataIndex: 'productTeamText',
          //   customRender: (text) => {
          //   if (!text) {
          //     return ''
          //   } else {
          //     return filterMultiDictText(this.dictOptions['productTeam'], text + '')
          //   }
          // },
            width: 91,
            ellipsis: true,
          },
          {
            title: '研发负责人',
            align: 'center',
            dataIndex: 'projLeadName',
            width: 75,
            ellipsis: true,
          //   customRender: (text) => {
          //   if (!text) {
          //     return ''
          //   } else {
          //     return filterMultiDictText(this.dictOptions['teamLeader'], text + '')
          //   }
          // }
          },
          {
            title: '任务说明',
            align: 'center',
            dataIndex: 'taskDescription',
            width: 113,
            ellipsis: true
          },
          
        ],
        columns2: [
          {
            title: '业务编码',
            align: 'center',
            key: 'ywfl'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['ywfl'], cellValue + '') : ''
            // }
          },
          {
            title: '业务名称',
            align: 'center',
            key: 'ywmc'
          },
          {
            title: '合同占比(%)',
            align: 'center',
            key: 'htzb',
            slotName: 'htzb',
            type: JVXETypes.slot
          },
          {
            title: '分配合同额（元）',
            align: 'center',
            key: 'fphte',
            slotName: 'fphte',
            type: JVXETypes.slot
          },
          {
            title: '切割合同额（元）',
            align: 'center',
            key: 'cutContractAmount',
            slotName: 'cutContractAmount',
            type: JVXETypes.slot
          },
          {
            title: '生产团队',
            align: 'center',
            key: 'sctd_dictText'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['sctd'], cellValue + '') : ''
            // }
          },
          // {
          //   title: '生产公司',
          //   align: 'center',
          //   key: 'productCompanyId_dictText'
          //   // formatter: ({ cellValue }) => {
          //   //   return cellValue ? filterMultiDictText(this.dictOptions['sctd'], cellValue + '') : ''
          //   // }
          // },
          {
            title: '团队负责人',
            align: 'center',
            key: 'tdfzr_dictText'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['tdfzr'], cellValue + '') : ''
            // }
          }
        ],
        contractTaxRateColumns: [
          {
            title: '含税金额(元)',
            align: 'center',
            key: 'ywfl'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['ywfl'], cellValue + '') : ''
            // }
          },
          {
            title: '税率(%)',
            align: 'center',
            key: 'ywmc'
          },
          {
            title: '税额(元)',
            align: 'center',
            key: 'htzb',
            slotName: 'htzb',
            type: JVXETypes.slot
          },
          {
            title: '未税金额(元)',
            align: 'center',
            key: 'fphte',
            slotName: 'fphte',
            type: JVXETypes.slot
          },
          {
            title: '备注',
            align: 'center',
            key: 'cutContractAmount',
            slotName: 'cutContractAmount',
            type: JVXETypes.slot
          },
          {
            title: '生产团队',
            align: 'center',
            key: 'sctd_dictText'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['sctd'], cellValue + '') : ''
            // }
          },
          // {
          //   title: '生产公司',
          //   align: 'center',
          //   key: 'productCompanyId_dictText'
          //   // formatter: ({ cellValue }) => {
          //   //   return cellValue ? filterMultiDictText(this.dictOptions['sctd'], cellValue + '') : ''
          //   // }
          // },
          {
            title: '团队负责人',
            align: 'center',
            key: 'tdfzr_dictText'
            // formatter: ({ cellValue }) => {
            //   return cellValue ? filterMultiDictText(this.dictOptions['tdfzr'], cellValue + '') : ''
            // }
          }
        ],
        columns3: [
          {
            title: '名称',
            align: 'center',
            dataIndex: 'gsdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['gsda'], text + '')
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        detailColumns: [
          {
            title: '业务编码',
            align: 'center',
            dataIndex: 'ywfl',
            width: 146,
            ellipsis: true
          },
          {
            title: '业务名称',
            align: 'center',
            dataIndex: 'ywmc',
            width: 146,
            ellipsis: true
          },
          {
            title: '合同占比(%)',
            align: 'center',
            dataIndex: 'htzb',
            width: 146,
            ellipsis: true
          },
          {
            title: '分配合同额（元）',
            align: 'center',
            dataIndex: 'fphte',
            width: 146,
            ellipsis: true
          },
          {
            title: '切割合同额（元）',
            align: 'center',
            dataIndex: 'cutContractAmount',
            width: 146,
            ellipsis: true
          },
          {
            title: '生产团队',
            align: 'center',
            dataIndex: 'sctd_dictText',
            width: 146,
            ellipsis: true
          },
          // {
          //   title: '生产公司',
          //   align: 'center',
          //   dataIndex: 'productCompanyId_dictText',
          //   width: 146,
          //   ellipsis: true
          // },
  
          {
            title: '团队负责人',
            align: 'center',
            dataIndex: 'tdfzr_dictText',
            width: 146,
            ellipsis: true
          }
        ],
        columns4: [
          {
            title: '名称',
            align: 'center',
            dataIndex: 'khdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['khda'], text + '')
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        dataSource: [], // 收付款计划数据源
        dataSource2: [], // 任务信息
        dataSource3: [], // 公司信息
        dataSource4: [], // 客户信息
        dictOptions: {},
        projectName: '',
        // 迭代11 委托方改为委托方(合同甲方)，受托方改为受托方（合同乙方）
        firstTitle: '委托方(合同甲方)信息',
        secondTitle: '受托方(合同乙方)信息',
        cust_lxr: '',
        glhtFlag: false,
        sfbg: false,
        detailFlag: false, // 查看详情状态
        isFkht: false,
        showKxxx: false,
        // 修改时加上当前行的值
        editRemain: 0,
        involveMultipleFlag: false,
        projectId: null,
        isNotHidden: false,
        otherKey: '',
        customKey: '',
        columnswidth: '',
        detailColumnswidth: ''
      }
    },
    computed: {
      getProject() {
        return this.model.xmmc
      },
      showByHtlx () {
        var type = this.model.htlx;
        if (type == '2') {
          this.$set(this.validatorRules, 'isCategoryType', [{ required: true, message: '请选择合同是否采购类!' }]);
        } else {
          this.$set(this, 'calibrationId', '');
          this.$delete(this.validatorRules, 'isCategoryType')
        }
        if (type == '1' || type == '2') {
          return true
        } else {
          return false
        }
      },
      formDisabled() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return true
          }
        }
        return false
      },
      isShowSeal () {
        if (this.model.sfyz && this.model.sfyz == 1) {
          return true
        } else {
          return false
        }
      },
      // 合同额剩余可分配值
      remainBchte() {
        if (this.model.bchte) {
          let remain = this.model.bchte + this.editRemain;
          this.dataSource.forEach(data => {
            remain -= data.je;
          })
          return remain;
        } else {
          return 0;
        }
      }
    },
    created() {
      
      // 备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      // 如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
      this.initDictConfig();
      this.formBpm && this.initRules();
      if (this.formDisabled) {
        // this.columns.pop()
        this.columns3.pop()
        this.columns4.pop()
      }
      this.otherKey = 'columns'
      this.customKey = 'detailColumns'
      this.columnswidth = this.columns.map(val => {
        return val.width
      })
      this.detailColumnswidth = this.detailColumns.map(val => {
        return val.width
      })
    },
    methods: {
     async sumbitFile(){
         let params = {
          id:this.$route.params.id,
          fileId:this.model.attachment
         }
        const res =  await getAction('/api/erp/omc/project/erpRAndDOmcProject/uploadFile',params)
        if(res.code !== 200) return this.$message.warning(res.message)
        this.$message.success(res.message)
        console.log(res,'res---');
        
      },

      handleChangeTab(key){
         console.log(key,'key');
      },

      changeProjectTab (val){
           console.log(val,'val');
           
      },

      threeLoadData() {
      this.progressListDataSource = []
      this.loading = true
      const params = {
        projectId: this.$route.params.id,
        pageNo: 1,
        pageSize: 10000,
        column: '',
        order: ''
      }
      if (this.projectIdTo) {
        params.projectId = this.projectIdTo
      }
      getAction('/api/erp/progress/development/erpProgressTask/progressList', params).then(res => {
        if (res.success) {
          this.progressListDataSource = res.result.records || []
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
      initRules() {
        const ruleStrategy = {
          tdhskj: {
            confirmIncomeMethod: [
              { required: true, message: '请选择收入确认方式!' }
            ]
          },
          rdsh: {
            distributionMethod: [
              { required: true, message: '请选择分配方式!' }
            ],
            businessPerformance: [
              { required: true, message: '请输入经营绩效!' }
            ],
          },
          rdqr: {
            distributionMethod: [
              { required: true, message: '请选择分配方式!' }
            ],
            businessPerformance: [
              { required: true, message: '请输入经营绩效!' }
            ],
          },
          qrhtgd: {
                      qdrq: [
                          { required: true, message: '请选择签订日期!' }
                      ],
                      sfcd: [
                          { required: true, message: '请选择是否存档!' }
                      ],
                      cdfs: [
                          { required: true, message: '请输入合同存档份数!' }
                      ],
                      contractFileType: [
                          { required: true, message: '请选择存档形式!' }
                      ],
                  }
        }
        if (this.formData && this.formData.extendUrlParams) {
          const rules = ruleStrategy[this.formData.extendUrlParams.node] || {}
          this.validatorRules = Object.assign(this.validatorRules, rules)
        }
        // this.$set(this, 'validatorRules', rules)
      },
      // 流程禁用
      checkDisabled(key) {
        if (this.formBpm) {
          const keyStrategy = {
            tdhskj: ['confirmIncomeMethod', 'rateList'], // 团队核算会计 - 收入确认方式，税率
            rdsh: ['distributionMethod', 'businessPerformance', 'classList'], // 入档审核 分配方式，经营绩效，任务信息列表，是否变更款项信息，收付款计划列表
            rdqr: ['distributionMethod', 'businessPerformance', 'classList'], // 入档审核 分配方式，经营绩效，任务信息列表，是否变更款项信息，收付款计划列表
            qrhtgd: [
              // 必填
              'htmc', 'jytd', 'yjgsnd', 'yzdw', 'qdrq', 'distributionMethod', 'ownerRole', 'contractChangeReason', 'masterCopy', 'sfcd', 'cdfs', 'contractFileType', 'bchte', 'fwqx', 'entrustList',
              'trusteeList', 'classList', 'sfbgkxxx', 'planList',
              // 非必填
              'lxr', 'lxfs', 'bz', 'yjxx', 'xgfj'
            ],
            // xmzy: ['instruction', 'taskFile', 'approvalEngineer']
          }
          if (this.formData && this.formData.extendUrlParams) {
            const ignoreKeys = keyStrategy[this.formData.extendUrlParams.node] || []
            if (ignoreKeys.includes(key)) {
              return false
            }
          }
          return true
        } else {
          // 新增编辑的时候禁用收入确认方式 - 签订日期
          if (key == 'confirmIncomeMethod' || key == 'qdrq' || key == 'sfcd' || key == 'cdfs' || key == 'contractFileType') {
            return true
          }
          return this.formDisabled
        }
      },
      // 选择下框架合同，关联框架合同置空
      handleChangeFrameContract () {
        this.$set(this.model, 'frameContractId', null);
        this.$refs.form.clearValidate('frameContractId'); // 切换清除校验
      },
      changeVal(val) {
        this.$set(this.model, 'businessCompanyId', val[0].belongCompanyId)
      },
      goPurchaseCalibrationDetail(record) {
        this.$refs.purchaseCalibrationBillPenetrate.initData(record.calibrationId);
        this.$refs.purchaseCalibrationBillPenetrate.visible = true;
      },
      goPurchaseApplyDetail(record) {
        this.$refs.purchaseApplyFormPenetrate.initData(record.purchaseApplyId);
        this.$refs.purchaseApplyFormPenetrate.visible = true;
      },
      goInvitationDetail(record) {
        this.$refs.purchaseInvitationFormPenetrate.initData(record.invitationId);
        this.$refs.purchaseInvitationFormPenetrate.visible = true;
      },
      async initDictConfig() {
        initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'sctd', res.result)
          }
        })
        initDictOptions('erp_employee_file,name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'tdfzr', res.result)
          }
        })
        initDictOptions('erp_purchase_supplier,enterprise_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'khda', res.result)
          }
        })
  
        initDictOptions('erp_company_files,file_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'gsda', res.result)
          }
        })
        // 收付款计划类型
        initDictOptions('org_payment_type').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'contractPaymentType', res.result)
          }
        })
      },
      handleAdd() {
        this.$refs.itemList.add();
        this.$refs.itemList.title = '新增';
        this.$refs.itemList.disableSubmit = false;
        // this.isFkht = false;
        this.isFkht = true;
      },
      handleEdit(record) {
        // 修改时将当前的值从remain中减去
        this.editRemain = record.je;
        this.$refs.itemList.edit(record);
        this.$refs.itemList.title = '编辑';
        // 修改经营团队的必填校验提示信息
        this.changejytdValidatorMessage()
        this.$refs.itemList.disableSubmit = false;
      },
      handleDetail(record) {
        // 修改时将当前的值从remain中减去
        this.editRemain = record.je;
        this.$refs.itemList.edit(record);
        this.$refs.itemList.title = '查看';
        this.$refs.itemList.disableSubmit = true;
      },
      handleDelete(data) {
        for (let i = 0; i < this.dataSource.length; i++) {
          if (this.dataSource[i].id == data.id) {
            this.dataSource.splice(i, 1);
          }
        }
        // 判断删除的款项类型是否为进度款
        if (data.contractPaymentType == 'progress') {
          // 筛选出款项类型为进度款的
          var index = 1
          this.dataSource.map(value => {
            if (value.contractPaymentType == 'progress') {
              value.kxmc = '进度款' + index;
              index++;
              return value
            }
          })
        }
      },
      handleAdd2() {
        this.$refs.itemList2.add();
        this.$refs.itemList2.title = '新增';
        this.$refs.itemList2.disableSubmit = false;
      },
      handleEdit2(record) {
        this.$refs.itemList2.edit(record);
        this.$refs.itemList2.title = '修改';
        this.$refs.itemList2.disableSubmit = false;
      },
      handleDelete2(id) {
        for (let i = 0; i < this.dataSource2.length; i++) {
          if (this.dataSource2[i].id == id) {
            this.dataSource2.splice(i, 1);
          }
        }
      },
      handleAdd3() {
        this.$refs.itemList3.add();
        this.$refs.itemList3.title = '新增';
        this.$refs.itemList3.disableSubmit = false;
      },
      handleEdit3(record) {
        this.$refs.itemList3.edit(record);
        this.$refs.itemList3.title = '修改';
        this.$refs.itemList3.disableSubmit = false;
      },
      handleDelete3(id) {
        for (let i = 0; i < this.dataSource3.length; i++) {
          if (this.dataSource3[i].id == id) {
            this.dataSource3.splice(i, 1);
          }
        }
      },
      handleAdd4() {
        this.$refs.itemList4.add();
        this.$refs.itemList4.title = '新增';
        this.$refs.itemList4.disableSubmit = false;
      },
      handleEdit4(record) {
        this.$refs.itemList4.edit(record);
        this.$refs.itemList4.title = '修改';
        this.$refs.itemList4.disableSubmit = false;
      },
      handleDelete4(id) {
        for (let i = 0; i < this.dataSource4.length; i++) {
          if (this.dataSource4[i].id == id) {
            this.dataSource4.splice(i, 1);
          }
        }
      },
      // 收付款计划的修改和新增回调
      modalFormOk(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource.length; i++) {
          if (this.dataSource[i].id == data.id) {
            this.dataSource.splice(i, 1, data);
            flag = false;
          }
        }
        // 判断删除的款项类型是否为进度款
        // 筛选出款项类型为进度款的
        var index = 1
        this.dataSource.map(value => {
          if (value.contractPaymentType == 'progress') {
            value.kxmc = '进度款' + index;
            index++;
            return value
          }
        })
        if (flag) {
          this.dataSource.push(data);
        }
        this.dataSourceSort()
        this.loading = false;
      },
      // 收付款计划排序
      dataSourceSort() {
        // 新增收付款计划后，子表按款项类型（首付款、进度款、尾款、全款）—质保金—履约保证金排序
          // 同一款项类型下，按照款项1-N排序
          const contractPaymentType =  this.dictOptions.contractPaymentType;
          contractPaymentType.push({ text: '履约保证金', title: '履约保证金', value: 'bail' }, { text: '质保金', title: '质保金', value: 'quality' })
          
          this.dataSource.sort((item1, item2) => {
            // 获取 item1 和 item2 在数据字典中的索引
            const index1 = contractPaymentType.findIndex(dictItem => dictItem.value === item1.contractPaymentType);
            const index2 = contractPaymentType.findIndex(dictItem => dictItem.value === item2.contractPaymentType);
            // 根据索引比较大小
            return index1 - index2;
          });
      },
      modalFormOk2(data) {
        if (!data.ywmc) return false // 如果没有填写数据
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource2.length; i++) {
          if (this.dataSource2[i].ywfl == data.ywfl) {
            this.dataSource2.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource2.push(data);
        }
        this.loading = false;
      },
      modalFormOk3(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource3.length; i++) {
          if (this.dataSource3[i].id == data.id) {
            this.dataSource3.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource3.push(data);
        }
        this.loading = false;
      },
      modalFormOk4(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource4.length; i++) {
          if (this.dataSource4[i].id == data.id) {
            this.dataSource4.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource4.push(data);
        }
        this.loading = false;
        this.initDictConfig()
      },
      yzdwChange(val) {
        this.$set(this.model, 'lxr', undefined);
        this.$set(this.model, 'lxfs', undefined);
        this.$set(this.model, 'enterpriseType', val && val[0] ? val[0].enterpriseType : ''); // 企业类型
        // this.cust_lxr = erp_omc_customer_manager_contact,lxr,id;
        this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
        // this.$set(this.model, 'lxr', undefined);
        // this.$set(this.model, 'lxfs', undefined);
      },
      lxrChange(val) {
        // debugger
        getAction('/api/erp/omc/customermanager/erpOmcCustomerManagerContact/queryById', { id: val }).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            // debugger;
            // this.model.lxdh = data.lxfs;
            this.$set(this.model, 'lxr', val)
            this.$set(this.model, 'lxfs', data.lxfs)
          }
        })
      },
      ...mapGetters(['userInfo']),
      add(type) {
        // 新增时，收付款计划需要直接新增两条数据 质保金和履约保证金
        this.$nextTick(() => {
          this.initPlanList('add') // 初始化收付款计划
          this.initTaxRateInfoList('add') // 初始化合同税率
        })
        this.dataSource2 = []
        this.dataSource3 = []
        this.dataSource4 = []
        this.modelDefault.lx = 1
        this.modelDefault.htlx = type
        this.sfbg = false;
        // this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss');
        // this.model.proposer = this.userInfo().empId;
        // this.model.proposerDeptId = this.userInfo().deptId;
        this.$set(this.modelDefault, 'proposer', this.userInfo().empId)
        this.$set(this.modelDefault, 'proposerDeptId', this.userInfo().deptId)
        this.$set(this.modelDefault, 'createTime', moment().format('YYYY-MM-DD HH:mm:ss'))
        this.edit(this.modelDefault);
        this.showKxxx = true;
        this.involveMultipleFlag = false;
        this.generatedFormNumber();
      },
      // 初始化收付款计划
      initPlanList(type) {
        if (type == 'add') {
          this.dataSource = [
            {
              id: parseInt(Math.random() * 1000000000000),
              contractPaymentType: 'bail', // 履约保证金类型
              contractPaymentType_dictText: '履约保证金', // 履约保证金类型
              kxmc: '履约保证金', // 款项名称
              je: null, // 金额
              planTaskList: [], // 任务信息
              collectMoneyStatus: '未生成', // 收款状态
              taskId_dictText: null // 款项关联任务
            },
            {
              id: parseInt(Math.random() * 1000000000000),
              contractPaymentType: 'quality', // 质保金类型
              contractPaymentType_dictText: '质保金', // 质保金类型
              kxmc: '质保金', // 款项名称
              je: null, // 金额
              kxrq: null, // 预计款项日期
              kxjdsm: null, // 款项节点说明
              planTaskList: [], // 任务信息
              collectMoneyStatus: '未生成', // 收款状态
              taskId_dictText: null // 款项关联任务
            }
          ]
        } else {
          this.dataSource = [] // 直接清空收付款计划
        }
      },
      // 初始化合同税率
      initTaxRateInfoList(type) {
        if (type == 'add') {
          // 税率
        initDictOptions('contract_rate_type').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'contractRateType', res.result)
            this.$refs.contractTaxRateInfoList.dataSource = this.dictOptions.contractRateType.map((item, index) => {
              return {
                key: index,
                amount: 0, // 含税金额
                taxRate: item.value, // 税率
                taxRate_dictText: item.text, // 税率
                taxation: 0, // 税额
                untaxedAmount: 0, // 未税金额
              } 
            })
          } else {
            this.$message.error(res.message)
          }
        })
        } else {
          this.$refs.contractTaxRateInfoList.dataSource = [] // 清空
        }
      },
      generatedFormNumber() {
        getAction(this.url.generatedFormNumber, { prefix: 'HT', subSystemCode: '05' }).then(res => {
          if (res.success) {
            this.$set(this.model, 'htbh', res.result)
          }
        })
      },
      add2(type) {
        this.$nextTick(() => {
          this.initPlanList('change') // 直接清空收付款计划
          this.initTaxRateInfoList('change') // 初始化合同税率
        })
        this.dataSource2 = []
        this.dataSource3 = []
        this.dataSource4 = []
        this.modelDefault.lx = 2
        this.sfbg = true
        this.modelDefault.htlx = type
        this.$set(this.modelDefault, 'proposer', this.userInfo().empId)
        this.$set(this.modelDefault, 'proposerDeptId', this.userInfo().deptId)
        this.$set(this.modelDefault, 'createTime', moment().format('YYYY-MM-DD HH:mm:ss'))
        this.edit(this.modelDefault);
        this.showKxxx = false;
        this.involveMultipleFlag = false;
        this.$set(this.validatorRules, 'sfyz', [{ required: true, message: '请选择是否用印!' }])
        this.generatedFormNumber();
      },
      async edit(record) {
        await this.$nextTick()
        this.$refs.form.resetFields();
        this.model = await Object.assign({}, record);
        this.model1 = await Object.assign({}, record);
        this.$set(this.model, 'skhtedx', convertCurrency(this.model.skhte))
        this.$set(this.model, 'bchtedx', convertCurrency(this.model.bchte))
        // 根据ID获取定标结果确认单单号 用于穿透
        if (this.formDisabled && this.model.calibrationId) {
          getAction(this.url.queryCalibrationById, { id: this.model.calibrationId }).then(res => {
            this.$set(this.model, 'calibrationNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        // 根据ID获取采购申请单单号 用于穿透
        if (this.formDisabled && this.model.purchaseApplyId) {
          getAction(this.url.queryPurchaseApplyById, { id: this.model.purchaseApplyId }).then(res => {
            this.$set(this.model, 'purchaseNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        // 根据ID获取采购申请单单号 用于穿透
        if (this.formDisabled && this.model.invitationId) {
          getAction(this.url.queryInvitationById, { id: this.model.invitationId }).then(res => {
            this.$set(this.model, 'invitationNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        if (record.lx == 2) {
          this.sfbg = true
          this.$set(this.validatorRules, 'caId', [{ required: true, message: '请选择合同编号!' }])
          this.$set(this.validatorRules, 'bglx', [{ required: true, message: '请选择变更类型!' }])
          this.$set(this.validatorRules, 'stopTime', [{ required: true, message: '请选择终止时间!' }])
          this.$set(this.validatorRules, 'sfyz', [{ required: true, message: '请选择是否用印!' }])
        } else {
          this.sfbg = false;
          this.$delete(this.validatorRules, 'caId')
          this.$delete(this.validatorRules, 'bglx')
          this.$delete(this.validatorRules, 'stopTime')
        }
        if (this.model && this.model.htlx) {
          if (this.model.isCategoryType) {
            this.handleChangeCategory(this.model.isCategoryType)
            if (this.model.provisionType) {
              this.handleChangeProvisionType(this.model.provisionType)
            }
          }
          this.projectName = this.model.xmmc_dictText
          if (this.model.htlx === '1' || this.model.htlx === 1) { // 收款合同
            // 客户
            // this.$refs.itemList4.isFk = true
            // // 公司
            // this.$refs.itemList3.isFk = false
            this.changeTitle(this.model.htlx)
          } else { // 付款合同
            // 客户
            // this.$refs.itemList4.isFk = false
            // // 公司
            // this.$refs.itemList3.isFk = true
            this.changeTitle(this.model.htlx)
          }
        } else { // 默认
          // 客户
          // this.$refs.itemList4.isFk = false
          // // 公司
          // this.$refs.itemList3.isFk = true
          this.changeTitle()
        }
        // 详情页去除表头中的操作
        if (this.formDisabled) {
          this.columns3.pop()
          this.columns4.pop()
        }
        this.$set(this, 'isFkht', this.model.htlx != '1')
        this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
        if (this.model.id) {
          // 收付款计划
          this.threeLoadData()
          getAction(this.url.queryPlanList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              // 初始化数据
              res.result = this.getInitDataSource(res.result)
              // res.result数组中的planTaskList数组中拼接categoryName形成款项关联任务
              res.result.map((value, index) => {
                res.result[index].taskId_dictText = '' // 首先款项关联任务字段默认为空
                // 遍历planTaskList数组赋值给taskId_dictText
                res.result[index].taskId_dictText = value.planTaskList && value.planTaskList.length ? (value.planTaskList.map((obj) => { return obj.categoryName }).join(',')) : '';
              })
              this.dataSource = res.result || res.result.records
            }
          })
  
          // 任务信息 20230421 收款合同存在任务，付款合同删除任务
          getAction(this.url.queryClassList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              this.dataSource2 = res.result.records || res.result
              this.dataSource2.forEach((item, index) => {
                // 是否有本次合同额
                if (this.model.bchte) {
                  if (this.model.distributionMethod == '1') {
                    // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
                    // item.fphte = parseFloat(item.htzb*0.01*parseFloat(this.model.bchte)).toFixed(2)
                    let amount = this.model.bchte * item.htzb / 100
                    item.fphte = Math.round((amount + Number.EPSILON) * 100) / 100
                  } else {
                    // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
                    let rate = item.fphte / this.model.bchte * 100
                    item.htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
                    // item.htzb = parseFloat(parseFloat(item.fphte) / parseFloat(this.model.bchte)*100).toFixed(2)
                  }
                } else {
                  if (this.model.distributionMethod == '1') {
                    // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
                    item.fphte = 0
                  } else {
                    // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
                    item.htzb = 0
                  }
                }
              })
            }
          })
          // 公司信息
          getAction(this.url.queryTrusteeList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              this.dataSource3 = res.result.records || res.result
            }
          })
  
          // 客户信息
          getAction(this.url.queryEntrustList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              this.dataSource4 = res.result.records || res.result
            }
          })
          // 合同税率
          // this.$refs.contractTaxRateInfoList.loadData('1', this.model.id) // 获取数据
          // getAction(this.url.queryEntrustList, { mainId: this.model.id }).then((res) => {
          //   if (res.success) {
          //     this.dataSource4 = res.result.records || res.result
          //   }
          // })
          this.showKxxx = this.model.lx == 2 ? this.model.sfbgkxxx == '1' : true
          this.glhtFlag = this.model.glskht == '1'
        }
        getAction('/api/erp/omc/project/erpRAndDOmcProjectTaskFinal/listById', { id: this.model.id }).then((res) => {
        if (res.length > 0) {
          this.devDataSource = res || res.result;
        }
      });
    //    this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss');
        // this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id';
        // this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
        this.involveMultipleFlag = record.involveMultiple == 1
        // 服务期限
        if (!!this.model.fwqx && !!this.model.fwqxEnd) {
          this.createTime = []
          this.createTime.push(this.model.fwqx)
          this.createTime.push(this.model.fwqxEnd)
        } else {
          this.createTime = []
        }
        this.skhtmcRequire(this.model.glskht)
        this.visible = true;
        this[this.otherKey].forEach((val, index) => {
          val.width = this[this.otherKey + 'width'][index]
        })
        this[this.customKey].forEach((val, index) => {
          val.width = this[this.customKey + 'width'][index]
        })
      },
      // 渲染流程表单数据
      showFlowData() {
        if (this.formBpm === true) {
          let params = { id: this.formData.dataId };
          getAction(this.url.queryById, params).then((res) => {
            if (res.success) {
              this.detailFlag = true;
              this.edit(res.result);
            }
          });
        }
      },
      valdateContractMoney() {
        // 判断收付款计划款项类型是否为空的
        let planType = this.dataSource.some(item => !item.contractPaymentType);
        if (planType) {
          message.warning('收付款计划中“款项类型”未填写，请重新填写!')
          return false;
        }
        let planSum = 0;
        this.dataSource.forEach(data => {
          // 去除履约保证金的金额相加
          if (data.contractPaymentType != 'bail') {
            planSum += parseFloat(data.je || 0);
          }
        });
        // 迭代11 TASK#3763 2.收付款计划栏金额与合同总金额不对等时不可以发起，需要校验核对收付款计划金额和合同总金额
        if (this.model.bchte.toFixed(2) != planSum.toFixed(2)) {
          message.warning('收付款计划中“金额”之和不等于“本次合同额”，请重新填写!')
          return false;
        }
        // 付款合同的本次合同额应该只是对外的任务的金额，不能校验本次合同额等于所有任务的总额
        if (this.model.htlx === 1 || this.model.htlx === '1') {
          if (this.model.distributionMethod == '1') {
            let rate = 0
            this.dataSource2.forEach(val => {
              rate += parseFloat(val.htzb)
            })
            if (rate != 100) {
              message.warning('任务信息中“合同占比”之和不等于100%，请重新填写!')
              return false;
            }
          } else {
            let total = 0
            this.dataSource2.forEach(val => {
              total += parseFloat(val.fphte)
            })
            if (total.toFixed(2) != parseFloat(this.model.bchte).toFixed(2)) {
              message.warning('任务信息中“分配合同额”之和不等于“本次合同额”，请重新填写!')
              return false;
            }
          }
        }
        return true;
      },
      onDetail(id, type) {
        const that = this
        if (type == 'project') {
          this.$nextTick(() => {
            getAction(this.url.queryProjectById, { id }).then((res) => {
              if (res.success) {
                const model = res.result
                that.$refs.projectModalForm.getDetail(model);
                that.$refs.projectModalForm.title = '项目一览表';
              }
            })
          })
        } else {
          getAction('/api/erp/omc/project/erpRAndDOmcProject/queryById', { id }).then((res) => {
            if (res.success) {
              const model = res.result
              this.contractVisible = true
              this.$nextTick(() => {
                this.$refs.contractManageForm.edit(model);
              })
              // this.model = model;
            }
          })
        }
      },
      handleCancel() {
        this.contractVisible = false;
      },
      // 处理首付款计划，新增sortOrder字段
      handelPlanList(list) {
        for (let i = 0; i < list.length; i++) {
          list[i].sortOrder = i;
        }
        return list;
      },
  
      // 判断需分配款项信息中的数据是否达到100%，如果达到则提交，否则提示需分配款项信息中的数据未达到100%
      handleJudgePayment() {
        var isTrue = true // true为通过，false为不通过
        // var _this = this
        var text = ''
        if (this.dataSource && this.dataSource.length > 0) {
          this.dataSource.forEach((item, index) => {
            // 判断当收付款计划中未达到应收状态时
            // 当collectMoneyStatus为未生成时，需要去除履约保证金的判断，因为履约保证金在未生成时，不参与判断
            if (item.collectMoneyStatus != '已生成' && item.contractPaymentType!= 'bail') {
              // 判断是否填写金额
              if (item.je=== null || item.je=== undefined || item.je === '') {
                text = `收付款计划中，款项名称为“${item.kxmc}”金额未填写!`
                  isTrue = false
              }
              // 在判断金额是否等于0 等于0 的情况下是不需要绑定任务的，所以不需要判断
              if (Number(item.je) !== 0) {
                if (item && item.planTaskList && item.planTaskList.length > 0) {
                  // 判断item1中的 paymentRate之和是否等于100%
                  // const listTotal = item.planTaskList.reduce((total, item1) => {
                  //   const paymentRate = Number(item1.paymentRate) || 0;
                  //   const decimalContractRate = new Decimal(paymentRate);
                  //   return total.plus(decimalContractRate);
                  // }, new Decimal(0)).toNumber(); // 解决浮点数导致两者不相等
                  // if (listTotal != 100) {
                  //   text = '收付款计划中，“款项关联任务”中“款项分配占比”没有达到100%！，请重新填写!'
                  //   isTrue = false
                  // }
                } else {
                  text = '收付款计划中，“款项关联任务”未绑定任务，需绑定任务!'
                  isTrue = false // 没有任务时，不允许通过
                }
              }
            }
          })
        }
        if (!isTrue) {
          this.$message.warning(text)
        }
        return isTrue
      },
      submitForm(type) {
        const that = this;
        if (type == 'draft') {
          // 代表保存草稿不做校验
          this.submit(type)
        } else if (type == 'submit') {
          // 触发表单验证
          this.$refs.form.validate(valid => {
            if (valid) {
              if (that.model.htlx === 1 || that.model.htlx === '1') {
                if (that.dataSource.length === 0) {
                  that.$message.warn('请填写“收付款计划”!');
                  that.confirmLoading = false
                  that.$emit('unButtonDisable');
                  return;
                }
              }
              const hasNullCutContractAmount = this.dataSource2.some(item => item.cutContractAmount === null)
              if (hasNullCutContractAmount) {
                this.$message.warning('请填写“任务信息”中切割合同额!')
                this.$emit('unButtonDisable');
                return
              }
              // 判断收款计划金额是否大于合同金额
              if (!this.valdateContractMoney()) {
                this.$emit('unButtonDisable');
                return;
              }
              // 迭代11 委托方和受托方列表需要校验两个分别必须至少有一条数据 是否为收付款单位有各且仅有一个
              if (!this.validateClientDetailAndTrusteeDetail()) {
                this.$emit('unButtonDisable');
                return;
              }
              // 这里判断需分配款项信息中的数据是否达到100%，如果达到则提交，否则提示需分配款项信息中的数据未达到100%
              if (!that.handleJudgePayment()) {
                that.$emit('unButtonDisable');
                return
              }
              // 判断税率中的含税金额之和等于本次合同额
              const contractTaxRatedataSource = that.$refs.contractTaxRateInfoList.submitForm() || []
              // 计算含税金额之和
              let rateSum = contractTaxRatedataSource.reduce((total, item) => {
                return total + Number(item.amount || 0)
              }, 0)
              if (rateSum.toFixed(2) != that.model.bchte.toFixed(2)) {
                that.$message.warning('合同税率中“含税金额”之和不等于“本次合同额”，请重新填写!')
                that.$emit('unButtonDisable');
                return
              }
              that.submit(type)
            } else {
              that.$emit('unButtonDisable')
            }
          })
        } else {
          console.log('传参数，保存：draft，提交：submit')
        }
      },
      submit (type) {
        const that = this;
        that.confirmLoading = true;
        this.isSubmit = false
        let httpurl = '';
        let method = '';
        if (!this.model.id) {
          httpurl += this.url.add;
          method = 'post';
        } else {
          httpurl += this.url.edit;
          method = 'put';
        }
        // 迭代11 标题修改
        that.model.bpmBizTitle = (this.projectName ? this.projectName + '-' : '') + that.userInfo().empName + (this.model.htbh ? ' - ' + this.model.htbh : '')
        console.log(that.model.bpmBizTitle,'that.model.bpmBizTitle---');
        
        let model = {};
        Object.assign(model, this.model)
        // if (model.bchte) {
          // this.$set(this.model,"yjhte",yjhte * 100)
        //   model.bchte = model.bchte * 100;
        // }
  
        // 收付款计划
        model.planList = this.handelPlanList(this.dataSource);
  
        // for (let i = 0; i < model.planList.length; i++) {
        //   // debugger;
        //   model.planList[i].je = model.planList[i].je * 100
        // }
  
        model.classList = this.dataSource2
        // 公司
        model.trusteeList = this.dataSource3 || [];
        // 客户
        model.entrustList = this.dataSource4 || [];
        // 税率
        model.rateList = that.$refs.contractTaxRateInfoList.submitForm() || [];
        httpAction(httpurl, model, method).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            if (method == 'post') {
              that.model.id = res.result;
            }
            that.$emit('ok', type, that.model);
            if (this.formBpm) {
              let params = { id: this.formData.dataId };
              getAction(this.url.queryById, params).then((res) => {
                if (res.success) {
                  this.model1 = res.result
                  this.isSubmit = true
                }
              });
              this.model1 = res.result
            }
          } else {
            that.$message.warning(res.message);
            that.$emit('unButtonDisable');
          }
        }).catch((error) => {
          that.$emit('unButtonDisable', error);
        }).finally(() => {
          that.confirmLoading = false;
        })
      },
      convertMoney1() {
        let money = this.model.skhte
        this.$set(this.model, 'skhtedx', convertCurrency(money))
      },
      convertMoney2() {
        let money = this.model.bchte
        this.$set(this.model, 'bchtedx', convertCurrency(money))
        this.dataSource2.forEach((item, index) => {
          if (this.model.bchte) {
            if (this.model.distributionMethod == '1') {
              // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
              // item.fphte = parseFloat(item.htzb*0.01*parseFloat(this.model.bchte)).toFixed(2)
              let amount = this.model.bchte * item.htzb / 100
              item.fphte = Math.round((amount + Number.EPSILON) * 100) / 100
            } else {
              // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
              let rate = item.fphte / this.model.bchte * 100
              item.htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
              // item.htzb = parseFloat(parseFloat(item.fphte) / parseFloat(this.model.bchte)*100).toFixed(2)
            }
          } else {
            if (this.model.distributionMethod == '1') {
              // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
              item.fphte = 0
            } else {
              // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
              item.htzb = 0
            }
          }
        })
      },
      // 切换项目 任务信息  数据占比信息改变
      changeMoney() {
        if (this.model.bchte && this.dataSource2.length) {
          this.dataSource2.forEach((item) => {
            if (this.model.distributionMethod == '1') {
              // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
              // item.fphte = parseFloat(item.htzb*0.01*parseFloat(this.model.bchte)).toFixed(2)
              let amount = this.model.bchte * item.htzb / 100
              item.fphte = Math.round((amount + Number.EPSILON) * 100) / 100
            } else {
              // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
              let rate = item.fphte / this.model.bchte * 100
              item.htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
              // item.htzb = parseFloat(parseFloat(item.fphte) / parseFloat(this.model.bchte)*100).toFixed(2)
            }
          })
        }
      },
      handleValueChange(event) {
        const { rowIndex, columnIndex, value } = event
        if (this.model.bchte) {
          if (columnIndex == 3) {
            let amount = this.model.bchte * value / 100
            this.dataSource2[rowIndex].fphte = Math.round((amount + Number.EPSILON) * 100) / 100;
          } else if (columnIndex == 4) {
            let rate = value / this.model.bchte * 100
            this.dataSource2[rowIndex].htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
          }
        }
      },
      handleJvxeChange(value, rowIndex, key) {
        if (this.model.bchte) {
          if (key == 'fphte') {
            let rate = value / this.model.bchte * 100
            this.dataSource2[rowIndex].htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
          } else {
            let amount = this.model.bchte * value / 100
            this.dataSource2[rowIndex].fphte = Math.round((amount + Number.EPSILON) * 100) / 100;
          }
        } else {
          this.dataSource2[rowIndex].htzb = 0
          this.dataSource2[rowIndex].fphte = 0
        }
      },
      xmmcChange(val) {
        // 清空项目也清空带出来的定标结果确认单数据
        this.handleChangeFrameContract() // 清空框架合同
        if (!val) {
          this.model.calibrationId = null
        }
        this.initPlanList('add') // 初始化收付款计划
        getAction(this.url.queryProject, { id: val }).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            this.$set(this.model, 'calibrationId', null) // 定标结果确认单
            this.$set(this.model, 'yzdw', data.ownerUnit) // 业主单位
            this.$set(this.model, 'businessCompanyId', data.businessCompanyId) // 
            this.$set(this.model, 'businessPerformance', data.businessPerformance) // 经营绩效
            this.$set(this.model, 'ownerRole', data.ownerRole || null) // 业主角色
            this.$set(this.model, 'mainProductionTeam', data.mainProductionTeam || null) // 主生产团队
            this.$set(this.model, 'enterpriseType', data.enterpriseType || null)// 企业类型
            // debugger;
            // this.model.lxdh = data.lxfs;
            this.$set(this.model, 'xmbh', data.finalNo) // 项目编号
            // 迭代16.7 选择灰色类型的团队不用带出团队
            if (this.model.feeType !== '2') {
              this.$set(this.model, 'jytd', data.oldTeamId ? data.oldTeamId : data.teamName) // 经营团队
            } else {
              this.$set(this.model, 'jytd', null) // 经营团队
            }
            this.$set(this.model, 'yjgsnd', data.year) // 业绩归属年度
            this.$set(this.model, 'qddw', data.signUnit) // 签定单位
            this.$set(this.model, 'xmcjr', data.undertaker) // 项目承接人
            this.$set(this.model, 'lxfs', data.contactTel) // 联系方式
            this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
            this.$set(this.model, 'lxr', data.contacts) // 联系人
            this.projectName = data.projectName
            // 收款合同查询任务信息
            // 任务信息
            getAction(this.url.queryClassList2, { projectId: data.id, pageNo: 1, pageSize: 999, distributionType: '!cancel' }).then((res) => {
              this.dataSource2 = []
              if (res.success) {
                let data = res.result.records || res.result
                for (let i = 0; i < data.length; i++) {
                  let d = {
                    'ywfl': data[i].categoryCode,
                    'ywmc': data[i].categoryName,
                    'htzb': data[i].contractRate,
                    'fphte': data[i].contractAmount,
                    'sctd': data[i].productTeam,
                    'sctd_dictText': data[i].productTeam_dictText,
                    'productCompanyId': data[i].productCompanyId,
                    'productCompanyId_dictText': data[i].productCompanyId_dictText,
                    'tdfzr': data[i].teamLeader,
                    'tdfzr_dictText': data[i].teamLeader_dictText,
                    'projectTaskId': data[i].id,
                    'cutContractAmount': data[i].cutContractAmount
                  };
                  //  相同任务分类只存在一条功能去除 2023年3月28日
                  this.dataSource2.push(d);
                  // let index = this.dataSource2.findIndex(item => item.ywfl == d.ywfl)
                  // if (index > -1) {
                  //   this.dataSource2.splice(index, 1, d)
                  // } else {
                  //   this.dataSource2.push(d);
                  // }
                }
                this.changeMoney()
              }
            })
            this.$set(this.model, 'distributionMethod', data.distributionMethod || '')
            this.bailChange(data.id) // 收付款计划获取最新的履约保证金
          }
          
        })
      },
      // 收付款计划获取最新的履约保证金
      bailChange(id) {
        var params = {
          preProjectId: id,
          feeCategory: '2',
          bpmStatus: '3'
        }
        // 查看项目保证金
        getAction(this.url.queryProjectDeposit, params).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            // 收付款计划履约保证金赋值
            this.dataSource.map((item) => {
              if (item.contractPaymentType == 'bail') {
                item.je = data.remittanceAmount
              }
            })
          } else {
            // 收付款计划履约保证金赋值
            this.dataSource.map((item) => {
              if (item.contractPaymentType == 'bail') {
                item.je = '0'
              }
            })
          }
        }).catch(err => {
          // 收付款计划履约保证金赋值
          this.dataSource.map((item) => {
            if (item.contractPaymentType == 'bail') {
              item.je = '0'
            }
          })
        })
      },
      htlxChange(val) {
        this.$set(this.model, 'htlx', val)
        if (val) {
          let url;
          if (val === '1') {
            // 合同类型为收款合同，需要做特殊处理
            // updated  by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
            // 修改前:  url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=true";
            // 修改后:
            url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=true';
            this.$set(this.model, 'glskht', '0')
            this.glhtFlag = false;
            this.skhtmcRequire(this.model.glskht)
            // 将受托方子modal中的是否显示付款改为false
            // this.$refs.itemList4.isFk = true
            // this.$refs.itemList3.isFk = false
            this.changeTitle(val)
          } else {
            // 合同类型为付款合同，需要做特殊处理
            // updated by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
            // 修改前: url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=false";
            // 修改后:
            url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=false';
            // 将受托方子modal中的是否显示付款改为true
            // this.$refs.itemList4.isFk = false
            // this.$refs.itemList3.isFk = true
            this.changeTitle(val)
          }
          this.$set(this, 'isFkht', val !== '1');
          this.$refs.projectModel.loadData(url);
        }
        // 切换合同类型时清空委托方、受托方信息
        this.dataSource4 = [];
        this.dataSource3 = [];
      },
      // 选择变更类型
      bglxInput () {
        this.$set(this.model, 'stopTime', null)
        this.$refs.form.clearValidate('stopTime')
      },
      glskhtChange(val) {
        this.$set(this.model, 'glskht', val)
        if (val) {
          this.skhtmcRequire(val)
          if (val === '1') {
            this.glhtFlag = true;
          } else {
            this.glhtFlag = false;
          }
        }
      },
      skhtmcRequire(val) {
        if (val == '1') {
          this.$set(this.validatorRules, 'skhtmc', [{ required: true, message: '请选择收款合同名称!' }]);
        } else {
          this.$set(this.model, 'skhtmc', '');
          this.$set(this.model, 'skhte', '');
          this.$set(this.model, 'skhtedx', '');
          this.$delete(this.validatorRules, 'skhtmc');
        }
      },
      changeTitle(args) {
         if (args == '1') { // 收款合同类型时
           this.firstTitle = '委托方(合同甲方)信息'
           this.secondTitle = '受托方(合同乙方)信息'
            // 修改列表表头
            this.$set(this, 'columns4', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'khdaId',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['khda'], text + '')
                  }
                }
              },
              {
                title: '是否为付款单位',
                align: 'center',
                dataIndex: 'isFk',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '对方是否电子签章',
                align: 'center',
                dataIndex: 'isSignSeal',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '对方盖章人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
              ])
              this.$set(this, 'columns3', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'gsdaId',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['gsda'], text + '')
                  }
                }
              },
              {
                title: '是否为收款单位',
                align: 'center',
                dataIndex: 'isSk',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '我方经办人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
            ])
         } else { // 付款合同类型时
           this.firstTitle = '受托方(合同乙方)信息'
           this.secondTitle = '委托方(合同甲方)信息'
           // 修改列表表头
            this.$set(this, 'columns4', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'khdaId',
                customRender: (text, record) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['khda'], text + '')
                  }
                }
              },
              {
                title: '是否为收款单位',
                align: 'center',
                dataIndex: 'isSk',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '对方是否电子签章',
                align: 'center',
                dataIndex: 'isSignSeal',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '对方盖章人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
              ])
              this.$set(this, 'columns3', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'gsdaId',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['gsda'], text + '')
                  }
                }
              },
              {
                title: '是否为付款单位',
                align: 'center',
                dataIndex: 'isFk',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '我方经办人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
            ])
        }
      },
      htbhChange(val) {
        this.handleChangeFrameContract() // 清空框架合同
        getAction('/api/erp/omc/project/erpRAndDOmcProject/queryById', { id: val }).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            // debugger;
            console.log(data,'data-------------');
            
            this.$set(this.model, 'caId', val)
            this.$set(this.model, 'bpmBizTitle', data.htmc) // 标题
            this.$set(this.model, 'htmc', data.htmc) // 合同名称
            this.$set(this.model, 'htlx', data.htlx) // 合同类型
            this.$set(this.model, 'estimatedContractAmount', data.estimatedContractAmount) // 
            this.$set(this.model, 'estimatedContractcapitalChineseAmount', data.estimatedContractcapitalChineseAmount) // 
            this.$set(this.model, 'estimatedPersonalFee', data.estimatedPersonalFee) // 
            this.$set(this.model, 'estimatedDirectPutFee', data.estimatedDirectPutFee) // 
            this.$set(this.model, 'estimatedDepreciationAmortizeFee', data.estimatedDepreciationAmortizeFee) // 
            this.$set(this.model, 'estimatedExperimentFee', data.estimatedExperimentFee) // 
            this.$set(this.model, 'estimatedOutsourceDevelopmentFee', data.estimatedOutsourceDevelopmentFee) // 
            this.$set(this.model, 'estimatedOtherFee', data.estimatedOtherFee) // 
            this.$set(this.model, 'actualDevelopmentFeeAmount', data.actualDevelopmentFeeAmount) // 
            this.$set(this.model, 'actualDevelopmentFeeChineseAmount', data.actualDevelopmentFeeChineseAmount) // 
            this.$set(this.model, 'actualPersonalFee', data.actualPersonalFee) // 
            this.$set(this.model, 'actualDirectPutFee', data.actualDirectPutFee) // 
            this.$set(this.model, 'actualDepreciationAmortizeFee', data.actualDepreciationAmortizeFee) // 
            this.$set(this.model, 'actualExperimentFee', data.actualExperimentFee) // 
            this.$set(this.model, 'actualOutsourceDevelopmentFee', data.actualOutsourceDevelopmentFee) // 
            this.$set(this.model, 'actualOtherFee', data.actualOtherFee) // 
            this.$set(this.model, 'teamName', data.teamName) // 
            this.$set(this.model, 'signUnit', data.signUnit) // 
            this.$set(this.model, 'supplierId', data.supplierId) // 
            this.$set(this.model, 'currentProjectStatus', data.currentProjectStatus) // 
            this.$set(this.model, 'conclusionStatus', data.conclusionStatus) // 
            this.$set(this.model, 'changeStatus', data.changeStatus) // 
  
            // this.$set(this.model, 'year', data.year) // 
            // this.$set(this.model, 'year', data.year) // 

            // this.$set(this.model, 'projectName', data.projectName) // 合同类型
            // this.$set(this.model, 'xmmc', data.xmmc) // 项目名称
            // this.$set(this.model, 'xmmc_dictText', data.xmmc) // 



            this.$set(this.model, 'businessPerformance', data.businessPerformance) // 经营绩效
            // fix:BUG#4955 合同变更-当合同类型为付款合同，带出的委托方、受托方信息错误 start
            this.htlxChange(data.htlx)
            // fix:BUG#4955 合同变更-当合同类型为付款合同，带出的委托方、受托方信息错误 end
            this.$set(this.model, 'xmmc', data.xmmc) // 项目名称
            this.$set(this.model, 'jytd', data.jytd) // 经营团队
            this.$set(this.model, 'businessCompanyId', data.businessCompanyId) // 经营公司
            this.$set(this.model, 'yjgsnd', data.yjgsnd)// 业绩归属年度
            this.$set(this.model, 'qddw', data.qddw) // 签订单位
            this.$set(this.model, 'xmcjr', data.xmcjr) // 项目承接人
            this.$set(this.model, 'yzdw', data.yzdw)// 业主单位
            this.$set(this.model, 'lxr', data.lxr)// 联系人
            this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
            this.$set(this.model, 'lxfs', data.lxfs) // 联系方式
            this.$set(this.model, 'qdrq', data.qdrq)// 签订日期
            this.$set(this.model, 'sfyz', data.sfyz)// 是否用印
            this.$set(this.model, 'noFormalContract', data.noFormalContract || '')// 是否无正式合同
            this.$set(this.model, 'signSealWay', data.signSealWay)// 用印类型
            this.$set(this.model, 'signFile', data.signFile)// 用印文件
            this.$set(this.model, 'yzlx', data.yzlx) // 印章类型
            this.$set(this.model, 'yyfs', data.yyfs)// 用印份数
            this.$set(this.model, 'sfcd', data.sfcd)// 是否存档
            this.$set(this.model, 'cdfs', data.cdfs)// 存档份数
            this.$set(this.model, 'contractFileType', data.contractFileType)// 存档形式
            this.$set(this.model, 'glskht', data.glskht) // 关联收款合同
            this.glhtFlag = data.glskht == '1'
            this.skhtmcRequire(data.glskht)
            this.$set(this.model, 'skhtmc', data.skhtmc) // 收款合同名称
            // this.$set(this.model, 'jf', data.yzdw) // 甲方
            this.$set(this.model, 'jf', data.jf)// 甲方
            this.$set(this.model, 'yf', data.yf)// 甲方
            // this.$set(this.model, 'yf', data.qddw) // 已方
            this.$set(this.model, 'skhte', data.skhte)// 收款合同额
            this.$set(this.model, 'skhtedx', data.skhtedx)// 收款合同额大写
            this.$set(this.model, 'businessPerformance', data.businessPerformance)// 经营绩效
            this.$set(this.model, 'feeType', data.feeType)// 费用类型
            this.$set(this.model, 'isFrameContract', data.isFrameContract)// 框架下合同
            this.$set(this.model, 'frameContractId', data.frameContractId)// 关联框架合同
            this.$set(this.model, 'ownerRole', data.ownerRole || null)// 业主角色
            this.$set(this.model, 'enterpriseType', data.enterpriseType || null)// 企业类型
            this.$set(this.model, 'mainProductionTeam', data.mainProductionTeam || null)// 主生产团队
            this.$set(this.model, 'confirmIncomeMethod', data.confirmIncomeMethod || null)// 收入确认方式
            this.$set(this.model, 'contractChangeReason', data.contractChangeReason || null)// 变更说明
            // 合同税率
            // this.$refs.contractTaxRateInfoList.loadData('1', data.id, this.model.lx) // 获取数据
            let bchte = data.bchte;
            // if (data.bchte) {
            //   bchte = data.bchte / 100
            // }
  
            this.$set(this.model, 'bchte', bchte)
            this.$set(this.model, 'bchtedx', data.bchtedx)
            this.$set(this.model, 'fwqx', data.fwqx)
            this.$set(this.model, 'fwqxEnd', data.fwqxEnd)
            // 服务期限
            if (!!this.model.fwqx && !!this.model.fwqxEnd) {
              this.createTime = []
              this.createTime.push(this.model.fwqx)
              this.createTime.push(this.model.fwqxEnd)
            } else {
              this.createTime = []
            }
            this.$set(this.model, 'bz', data.bz) // 备注
            this.$set(this.model, 'yjxx', data.yjxx) // 邮寄信息
            this.$set(this.model, 'attachment', data.attachment) // 相关附件
            this.$set(this.model, 'htbh', data.htbh) // 合同编号
            this.$set(this.model, 'xmbh', data.xmbh) // 合同编号
  
            this.$set(this.model, 'isCategoryType', data.isCategoryType) // 是否采购类
            this.$set(this.model, 'provisionType', data.provisionType) // 采购类型
            this.$set(this.model, 'calibrationId', data.calibrationId) // 定标结果确认单
            this.$set(this.model, 'purchaseApplyId', data.purchaseApplyId) // 采购申请单
            this.$set(this.model, 'invitationId', data.invitationId) // 招标采购申请单
            this.handleChangeCategory(data.isCategoryType)
            if (data.isCategoryType == '1') {
              this.handleChangeProvisionType(data.provisionType)
            }
            this.$set(this.model, 'bglx', data.bglx)
            if (this.model.bglx && this.model.bglx == '2') {
              this.$set(this.model, 'stopTime', data.stopTime || null)
            }
            this.$set(this.model, 'sfbgkxx', data.sfbgkxx)
            // this.$set(this.model, 'proposer', data.proposer)
            // this.$set(this.model, 'proposerDeptId', data.proposerDeptId)
            this.$set(this, 'isFkht', data.htlx != '1')
            this.$set(this.model, 'involveMultiple', data.involveMultiple)
            this.$set(this, 'involveMultipleFlag', data.involveMultiple == 1)
            this.$set(this.model, 'masterCopy', data.masterCopy) // 合同原件
            // this.yzdwChange();
            this.$set(this.model, 'distributionMethod', data.distributionMethod || '')
            // 收款计划
            getAction('/api/erp/omc/contractmanager/erpOmcContractManagerPlanFinal/listAll', { mainId: val }).then((res) => {
              if (res.success) {
                // 为了老合同能变更，这里需判断收付款计划的款项类型是否包含了质保金和履约保证金，如果没有则需添加
                res.result = this.getInitDataSource(res.result)
                // res.result数组中的planTaskList数组中拼接categoryName形成款项关联任务
                res.result.map((value, index) => {
                  res.result[index].taskId_dictText = '' // 首先款项关联任务字段默认为空
                  // 遍历planTaskList数组赋值给taskId_dictText
                  res.result[index].taskId_dictText = value.planTaskList && value.planTaskList.length ? (value.planTaskList.map((obj, ind) => {
                    value.planTaskList[ind].finalId = obj.id
                    return obj.categoryName
                  }).join(',')) : '';
                })
                this.dataSource = res.result.records || res.result
                if (this.dataSource.length > 0) {
                  this.dataSource.forEach((item, index) => {
                    item.finalId = item.id
                  })
                }
                this.bailChange(data.xmmc) // 收付款计划获取最新的履约保证金
              }
            })
            // 任务信息
            // getAction('/api/erp/omc/contractmanager/erpOmcContractManagerClassFinal/listAll', { mainId: val }).then((res) => {
            getAction('/api/erp/omc/project/erpOmcProjectTask/listContractFinalTaskByProjectId', { projectId: data.xmmc }).then((res) => {
              let source = res || []
              this.dataSource2 = []
              if (source.length) {
                for (let i = 0; i < source.length; i++) {
                  let d = {
                    'ywfl': source[i].categoryCode,
                    'ywmc': source[i].categoryName,
                    'htzb': source[i].contractRate,
                    'fphte': source[i].contractAmount,
                    'sctd': source[i].productTeam,
                    'shouldPayFlag': source[i].shouldPayFlag, // 是否应收
                    'distributionType': source[i].distributionType, // 是否作废
                    'sctd_dictText': source[i].productTeam ? filterMultiDictText(this.dictOptions['sctd'], source[i].productTeam + '') : '',
                    'tdfzr': source[i].teamLeader,
                    'tdfzr_dictText': source[i].teamLeader ? filterMultiDictText(this.dictOptions['tdfzr'], source[i].teamLeader + '') : '',
                    'projectTaskId': source[i].id,
                    'cutContractAmount': source[i].cutContractAmount,
                    'productCompanyId':source[i].productCompanyId,
                    'productCompanyId_dictText': source[i].productCompanyId ? filterMultiDictText(this.dictOptions['gsda'], source[i].productCompanyId + '') : '',
  
                  };
                  this.dataSource2.push(d);
                }
              }
            })
            // 项目赋值
            getAction(this.url.queryProject, { id: data.xmmc }).then((res) => {
              if (res.success) {
                let data = res.result.records || res.result
                this.$set(this, 'projectName', data.projectName); // 项目名称
              }
            })
              // 受托方信息
              getAction('/api/erp/omc/contractmanager/erpOmcContractManagerTrusteeFinal/listAll', { mainId: val }).then((res) => {
                if (res.success) {
                  this.dataSource3 = res.result.records || res.result
                  this.dataSource3.forEach((item, index) => {
                    item.finalId = item.id
                  })
                }
              })
              // 委托方信息
              getAction('/api/erp/omc/contractmanager/erpOmcContractManagerEntrustFinal/listAll', { mainId: val }).then((res) => {
                if (res.success) {
                  this.dataSource4 = res.result.records || res.result
                  this.dataSource4.forEach((item, index) => {
                    item.finalId = item.id
                  })
                }
              })
          }
        })
      },
      // 接口获取收付款计划时当无质保金和履约保证金时，初始化数据
      getInitDataSource (arr) {
        // 为了老合同能变更，这里需判断收付款计划的款项类型是否包含了质保金和履约保证金，如果没有则需添加
        const index = arr.findIndex(item => item.contractPaymentType == 'bail');
        if (index == -1) {
          arr = [
            ...arr,
            {
              id: parseInt(Math.random() * 1000000000000),
              contractPaymentType: 'bail', // 履约保证金类型
              contractPaymentType_dictText: '履约保证金', // 履约保证金类型
              kxmc: '履约保证金', // 款项名称
              je: null, // 金额
              planTaskList: [], // 任务信息
              collectMoneyStatus: '未生成', // 收款状态
              taskId_dictText: null // 款项关联任务
            },
            {
              id: parseInt(Math.random() * 1000000000000),
              contractPaymentType: 'quality', // 质保金类型
              contractPaymentType_dictText: '质保金', // 质保金类型
              kxmc: '质保金', // 款项名称
              je: null, // 金额
              kxrq: null, // 预计款项日期
              kxjdsm: null, // 款项节点说明
              planTaskList: [], // 任务信息
              collectMoneyStatus: '未生成', // 收款状态
              taskId_dictText: null // 款项关联任务
            }
          ];
        }
        return arr
      },
      skhtBack (item) {
        // this.$set(this.model, 'skhtmc', item[0].id)
        this.$set(this.model, 'jf', item[0].qddw)
        this.$set(this.model, 'skhte', item[0].bchte)
        this.$set(this.model, 'skhtedx', item[0].bchtedx)
      },
      handleChangeSfbgkxxx(val) {
        this.$set(this.model, 'sfbgkxxx', val);
        this.$set(this, 'showKxxx', val == '1');
      },
      handleChangeSeal(val) {
        this.$refs.form.clearValidate([ 'noFormalContract', 'signSealWay', 'yzlx', 'yyfs', 'masterCopy', 'signFile']);
        if (val == 0) {
          this.$set(this.validatorRules, 'masterCopy', [{ required: true, message: '请上传合同原件!' }]);
          this.$set(this.model, 'noFormalContract', '0') // 置空无正式合同
          if (this.dataSource3 && this.dataSource3.length) {
            this.dataSource3.forEach(value => {
              value.psnName = null
              value.psnMobile = null
              return value
            })
          }
          if (this.dataSource4 && this.dataSource4.length) {
            this.dataSource4.forEach(value => {
              value.isSignSeal = '0'
              value.psnName = null
              value.psnMobile = null
              return value
            })
          }
        } else {
          this.$set(this.model, 'masterCopy', '');
          this.$delete(this.validatorRules, 'masterCopy');
          this.$set(this.model, 'noFormalContract', '') // 置空无正式合同
        }
        this.$set(this.model, 'signSealWay', null) // 置空电子签章
      },
      handleChangeSignSealWay (val) {
        if (val != 'online') {
          if (this.dataSource3 && this.dataSource3.length) {
            this.dataSource3.forEach(value => {
              value.psnName = null
              value.psnMobile = null
              return value
            })
          }
          if (this.dataSource4 && this.dataSource4.length) {
            this.dataSource4.forEach(value => {
              value.isSignSeal = '0'
              value.psnName = null
              value.psnMobile = null
              return value
            })
          }
        } else {
          if (this.dataSource4 && this.dataSource4.length) {
            this.dataSource4.forEach(value => {
              value.isSignSeal = '0'
              value.psnName = null
              value.psnMobile = null
              return value
            })
          }
        }
      },
      handleChangeCategory(val) {
        if (val == '1') {
          this.$set(this.validatorRules, 'provisionType', [{ required: true, message: '请选择采购类型!' }]);
        } else {
          this.$set(this.model, 'provisionType', null);
          this.$delete(this.validatorRules, 'provisionType');
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        }
      },
      handleChangeProvisionType(val) {
        if (val == '1') {
          this.$set(this.validatorRules, 'calibrationId', [{ required: true, message: '请选择定标结果确认单!' }]);
          // 清除采购申请单数据及校验
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        } else if (val == '2') {
          this.$set(this.validatorRules, 'purchaseApplyId', [{ required: true, message: '请选择采购申请单!' }]);
          // 清除定标结果确认单数据及校验
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        } else if (val == '3') {
          this.$set(this.validatorRules, 'invitationId', [{ required: true, message: '请选择招标采购申请单!' }]);
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
        } else {
          // 清除采购申请单数据及校验
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
          // 清除定标结果确认单数据及校验
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
        }
      },
      changeBizTitle() {
        this.model.bpmBizTitle = this.model.htmc
      },
      // 服务期限开始时间 结束时间
      createTimeChange(date, dateString) {
        this.$set(this.model, 'fwqx', dateString[0] + ' 00:00:00')
        this.$set(this.model, 'fwqxEnd', dateString[1] + ' 23:59:59')
      },
      // 校验委托方和受托方子表数据合法性 委托方和受托方列表需要校验两个分别必须至少有一条数据 是否为收付款单位有各且仅有一个
      validateClientDetailAndTrusteeDetail() {
        if (this.model.htlx == '1') { // 收款合同 dataSource4 客户为委托方（付款）
          // 委托方(合同甲方)信息校验
          if (!!this.dataSource4 && this.dataSource4.length == 0) {
            message.warning('请填写委托方信息!')
            return false;
          } else {
            let hasFkList = this.dataSource4.filter(item => item.isFk == '1');
            if (hasFkList.length <= 0) {
              message.warning('委托方必须有一个付款单位!')
              return false;
            }
            // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
            // let psnName = this.dataSource4.filter(item => item.psnName);
            // let psnMobile = this.dataSource4.filter(item => item.psnMobile);
            if (this.isShowSeal && this.model.signSealWay == 'online') {
              // 当主表选择了电子签章
              for (var i = 0; i < this.dataSource4.length; i++) {
                if (this.dataSource4[i].isSignSeal && this.dataSource4[i].isSignSeal == 1) {
                  if (!this.dataSource4[i].psnName || !this.dataSource4[i].psnMobile) {
                    message.warning('请填写委托方联系人和联系方式!')
                    return
                  }
                }
              }
            }
          }
          // 受托方(合同乙方)信息校验
          if (!!this.dataSource3 && this.dataSource3.length == 0) { // 收款合同 dataSource3 公司为受托方（收款）
            message.warning('请填写受托方信息!')
            return false;
          } else {
            let hasSkList = this.dataSource3.filter(item => item.isSk == '1');
            if (hasSkList.length != 1) {
              message.warning('受托方有且仅有一个是收款单位!')
              return false;
            }
            // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
            let psnName = this.dataSource3.filter(item => !item.psnName);
            let psnMobile = this.dataSource3.filter(item => !item.psnMobile);
            if (this.isShowSeal && this.model.signSealWay == 'online') {
              // 当主表选择了电子签章
              if (psnName.length || psnMobile.length) {
                message.warning('请填写受托方联系人和联系方式!')
              return false;
              }
            }
          }
          return true;
        } else { // 付款合同 dataSource3 公司为委托方（付款）
          // 委托方(合同甲方)信息校验
          if (!!this.dataSource3 && this.dataSource3.length == 0) {
            message.warning('请填写委托方信息!');
            return false;
          } else {
            let hasFkList = this.dataSource3.filter(item => item.isFk == '1');
            if (hasFkList.length != 1) {
              message.warning('委托方有且仅有一个是付款单位!')
              return false;
            }
            // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
            let psnName = this.dataSource3.filter(item => !item.psnName);
            let psnMobile = this.dataSource3.filter(item => !item.psnMobile);
            if (this.isShowSeal && this.model.signSealWay == 'online') {
              // 当主表选择了电子签章
              if (psnName.length || psnMobile.length) {
                message.warning('请填写委托方联系人和联系方式!')
              return false;
              }
            }
          }
          // 受托方(合同乙方)信息校验
          if (!!this.dataSource4 && this.dataSource4.length == 0) {
            message.warning('请填写受托方信息!');
            return false;
          } else {
            let hasSkList = this.dataSource4.filter(item => item.isSk == '1');
            if (hasSkList.length != 1) {
              message.warning('受托方有且仅有一个是收款单位!')
              return false;
            }
            // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
            // let psnName = this.dataSource4.filter(item => item.psnName);
            // let psnMobile = this.dataSource4.filter(item => item.psnMobile);
            if (this.isShowSeal && this.model.signSealWay == 'online') {
              // 当主表选择了电子签章
              for (var i = 0; i < this.dataSource4.length; i++) {
                if (this.dataSource4[i].isSignSeal && this.dataSource4[i].isSignSeal == 1) {
                  if (!this.dataSource4[i].psnName || !this.dataSource4[i].psnMobile) {
                    message.warning('请填写受托方联系人和联系方式!')
                    return
                  }
                }
              }
            }
          }
          return true;
        }
      },
  
      // 点击打印
      onPrint () {
          let print = new Print({
            el: '#contractmanageContent',
            popTitle: '项目收款合同申请详情 · 禾美环保',
            endCallback() {
  
            }
          })
        },
      /*
      * 费用类型修改的时候逻辑
      * 生产费用：把经营团队带出来
      * 经营费用：把费用所属团队清空
      * */
      handleFeeTypeChange() {
        // 修改经营团队的必填校验提示信息
        this.changejytdValidatorMessage()
        if (this.model.feeType === '2') { // 经营费用
          this.$set(this.model, 'jytd', null)
        } else { // 其他
          // 如果有项目自动带出项目中的经营团队
          if (this.model.xmmc) {
            getAction(this.url.queryProject, { id: this.model.xmmc }).then((res) => {
              if (res.success) {
                let data = res.result.records || res.result
                this.$set(this.model, 'jytd', data.oldTeamId ? data.oldTeamId : data.teamName)
              }
            })
          }
        }
      },
      // fix:BUG#7077 当费用类型为经营费用，费用所属团队必填项未填写，应提示“请选择费用所属团队”
      changejytdValidatorMessage() {
        if (!!this.validatorRules && !!this.validatorRules.jytd) {
          this.$refs.form.clearValidate('jytd');
          if (this.model.feeType === '2') { // 经营费用
            // 修改提示
            this.$set(this.validatorRules, 'jytd', [
              { required: true, message: '请选择费用所属经营团队!' }
            ])
          } else { // 其他
            // 修改提示
            this.$set(this.validatorRules, 'jytd', [
              { required: true, message: '请选择经营团队!' }
            ])
          }
        }
      }
    }
  }
  </script>
  <style>
    @import "../../../../../utils/print.css";
  .print_style{
    position: absolute;
    top: 0;
    z-index: -1111;
  }
  </style>
  